from django.db import models

# Create your models here.
# Create your models here.
# 一类
# 图书类
class BookInfo(models.Model):
    # 图书名称
    btitle = models.CharField(max_length=20)
    # 出版日期
    bpub_date = models.DateField()

    def __str__(self):
        return self.btitle

# 多类
# 英雄人物类
class HeroInfo(models.Model):
    # 英雄名称
    hname = models.CharField(max_length=20)
    # 性别
    hgender = models.BooleanField(default=False)
    # 备注
    hcomment = models.CharField(max_length=128)
    # 外键 对应图书类
    hbook = models.ForeignKey('BookInfo', on_delete=models.CASCADE)

    def __str__(self):
        return self.hname